home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 26.zip
/
BS1 part 26
/
C for beginners.adf
/
source
/
copier.c
< prev
next >
Wrap
C/C++ Source or Header
|
1978-01-17
|
1KB
|
52 lines
/* copier.c 23.2.1 */
#include <stdio.h>
main(argc, argv)
int argc;
char *argv[];
{
long copy(); /*If it is interesting */
if(argc !=3)
{
printf("Bad Arguments!\n");
printf("From_file to_file\n");
}
else
copy(argv[1], argv[2]);
}
copy(fromfile, tofile) /* Copy Routine */
char *fromfile, *tofile;
{
FILE *input, *output, *fopen();
register long counter = 0;
register int c;
if(!(input = fopen(fromfile, "rb")))
/* Open as Binary file */
{
printf("%s can not be opened!\n", fromfile);
return 0L;
}
if(!(output = fopen(tofile, "wb")))
{
printf("%s can not be opened!\n", tofile);
fclose(input); /* Was OK */
return 0L;
}
while( (c = fgetc(input)) !=EOF)
{
fputc( c, output);
counter++;
}
fclose(input);
fclose(output);
printf("\n%ld Bytes copied!\n", counter);
return(counter);
}